package com.example.zhuopeng.graduateddesign.util;

import android.content.Context;
import android.util.Log;

import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;

/**
 * Created by zhuopeng on 2018/4/10.
 */

public class ALocationClientFactory {
    private static final String TAG = "ALocationClientFactory";
    public static AMapLocationClientOption createDefaultOption(){
        Log.d(TAG,"createDefaultOption");
        AMapLocationClientOption option = new AMapLocationClientOption();
        //设置定位模式为高精度模式，Battery_Saving为低功耗模式，Device_Sensors是仅设备模式
        option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
        //设置定位间隔,单位毫秒,默认为2000ms，最低1000ms。
        option.setInterval(1000);
        option.setMockEnable(true);
        return option;
    }

    public static AMapLocationClient createLocationClient(Context context, AMapLocationClientOption option) {
        AMapLocationClient client = new AMapLocationClient(context);
        client.setLocationOption(option);
        return client;
    }
    public static AMapLocationClient createDefaultLocationClient(Context context) {
        return createLocationClient(context, createDefaultOption());
    }

}
